package team.kirohuji.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 权限
 * @author kirohuji
 *
 */
@Entity
@Table(name = "priority")
public class Priority implements Serializable {

	private static final long serialVersionUID = -4009734077571973745L;

	/**
	 * 权限Id
	 */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="priority_id")
	private Integer priorityId;
	/**
	 * 父级权限Id
	 */
	private Integer parentId;

	/**
	 * 权限名称
	 */
	private String name;

	/**
	 * 请求路径
	 */
	private String url;

	/**
	 * 授权
	 */
	private String perms;// 授权

	/**
	 * 节点类型： 0：目录 1：菜单 2：按钮
	 */
	private Integer nodeType;// 节点类型： 0：目录 1：菜单 2：按钮

	/**
	 * 权限状态：0暂停，1启用
	 */
	private Integer status;// 权限状态：0暂停，1启用

	/**
	 * 权限图标icon
	 */
	private String icon;// 权限图标icon

	/**
	 * 显示顺序
	 */
	private Integer showOrder;// 显示顺序

	/**
	 * 描述
	 */
	private String description;

	/**
	 * 限权类型：0-系统后台用户权限，1-微信端用户权限
	 */
	private Integer priorityType;// 限权类型：0-系统后台用户权限，1-微信端用户权限


	/**
	 * 是否打开
	 */
	private Boolean open;

	/**
	 * 父菜单名称
	 */
	private String parentName;// 父菜单名称
	
	/**
	 * 角色列表
	 */
    @ManyToMany (cascade = CascadeType.REFRESH)
    @JsonIgnore
    @JoinTable(name = "priority_role", joinColumns = {
            @JoinColumn(name = "fpriority_id", referencedColumnName = "priority_id")}, inverseJoinColumns = {
            @JoinColumn(name = "frole_id", referencedColumnName = "role_id")})
	private List<Role> roles;
    
	/**
	 * 列表
	 */
    @Transient
	private List<Priority> list;
	
	public List<Priority> getList() {
		return list;
	}

	public void setList(List<Priority> list) {
		this.list = list;
	}

	public Integer getPriorityId() {
		return priorityId;
	}

	public void setPriorityId(Integer priorityId) {
		this.priorityId = priorityId;
	}

	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getPerms() {
		return perms;
	}

	public void setPerms(String perms) {
		this.perms = perms;
	}

	public Integer getNodeType() {
		return nodeType;
	}

	public void setNodeType(Integer nodeType) {
		this.nodeType = nodeType;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public Integer getShowOrder() {
		return showOrder;
	}

	public void setShowOrder(Integer showOrder) {
		this.showOrder = showOrder;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getPriorityType() {
		return priorityType;
	}

	public void setPriorityType(Integer priorityType) {
		this.priorityType = priorityType;
	}
	public Boolean getOpen() {
		return open;
	}

	public void setOpen(Boolean open) {
		this.open = open;
	}

	public String getParentName() {
		return parentName;
	}

	public void setParentName(String parentName) {
		this.parentName = parentName;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	@Override
	public String toString() {
		return "Priority [priorityId=" + priorityId + ", parentId=" + parentId + ", name=" + name + ", url=" + url
				+ ", perms=" + perms + ", nodeType=" + nodeType + ", status=" + status + ", icon=" + icon
				+ ", showOrder=" + showOrder + ", description=" + description + ", priorityType=" + priorityType
				+ ", open=" + open + ", parentName=" + parentName + ", roles=" + roles + "]";
	}
	
	
}